package com.itheima.request;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/RefererServlet")
public class RefererServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        /*referer:浏览器通知服务器来自哪里*/
        String referer = request.getHeader("referer");
        System.out.println(referer);

        System.out.println("-------------");

        /*use-agent:浏览器版本不同,服务器区分不同的浏览器,可以做到浏览器兼容性处理*/
        String agent = request.getHeader("user-agent");
        System.out.println(agent);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
